/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Menu.java
 *
 * Created on 25/01/2010, 12:27:26
 */
package br.com.sofp.Visao;

import br.com.sofp.Util.JDesktopPanePersonalizado;
import br.com.sofp.Util.VerificaFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.LookAndFeel;

/**
 *
 * @author Daniel
 */
public class Menu extends javax.swing.JFrame {

    private TipoContaVisao tcv;
    private CadastroModelo cm;
    private Daniel_Cadastro dc;
    private teste te;
    private ValidandoHeranca vh;
    //  protected static final LookAndFeel  liq = new com.birosoft.liquid.LiquidLookAndFeel();

    /** Creates new form Menu */
    public Menu() {
        initComponents();
        //jLimagem.setLocation(this.getX()+150, this.getY());


        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
            //UIManager.setLookAndFeel(new com.jgoodies.looks.plastic.Plastic3DLookAndFeel());
            //UIManager.setLookAndFeel(new com.birosoft.liquid.LiquidLookAndFeel());
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "erro.. " + e);
        }



    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jpFundoPrincipal = new javax.swing.JPanel();
        jpRodape = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jpAreaTrabalho = new javax.swing.JPanel();
        String caminhoImagem = "/br/com/sofp/imagem/VB180.jpg";
        String nomeImagem = "VB180.jpg";
        dpPrincipal = new JDesktopPanePersonalizado(caminhoImagem, nomeImagem);
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jpBarraBotoes = new javax.swing.JPanel();
        mbMenu = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentMenuItem = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();

        jButton1.setText("jButton1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SISTEMA DE ORÇAMENTO FINACEIRO PESSOAL (SOFP)");
        setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH);

        jpFundoPrincipal.setPreferredSize(new java.awt.Dimension(570, 500));
        jpFundoPrincipal.setLayout(new java.awt.BorderLayout());

        jpRodape.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setFont(new java.awt.Font("Times New Roman", 0, 10));
        jLabel1.setText("Usuário logado: ");

        javax.swing.GroupLayout jpRodapeLayout = new javax.swing.GroupLayout(jpRodape);
        jpRodape.setLayout(jpRodapeLayout);
        jpRodapeLayout.setHorizontalGroup(
            jpRodapeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpRodapeLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(456, Short.MAX_VALUE))
        );
        jpRodapeLayout.setVerticalGroup(
            jpRodapeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1)
        );

        jpFundoPrincipal.add(jpRodape, java.awt.BorderLayout.PAGE_END);

        jpAreaTrabalho.setBackground(new java.awt.Color(0, 255, 204));

        dpPrincipal.setBackground(new java.awt.Color(255, 255, 255));
        dpPrincipal.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));

        jButton2.setMnemonic('0');
        jButton2.setText("Daniel");
        jButton2.setFocusable(false);
        jButton2.setHorizontalAlignment(javax.swing.SwingConstants.LEADING);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jButton2.setBounds(50, 30, 70, 30);
        dpPrincipal.add(jButton2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton3.setText("form teste");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jButton3.setBounds(200, 60, 120, 25);
        dpPrincipal.add(jButton3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton4.setText("Herança");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jButton4.setBounds(200, 130, 120, 25);
        dpPrincipal.add(jButton4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout jpAreaTrabalhoLayout = new javax.swing.GroupLayout(jpAreaTrabalho);
        jpAreaTrabalho.setLayout(jpAreaTrabalhoLayout);
        jpAreaTrabalhoLayout.setHorizontalGroup(
            jpAreaTrabalhoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(dpPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 542, Short.MAX_VALUE)
        );
        jpAreaTrabalhoLayout.setVerticalGroup(
            jpAreaTrabalhoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(dpPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
        );

        jpFundoPrincipal.add(jpAreaTrabalho, java.awt.BorderLayout.CENTER);

        jpBarraBotoes.setBackground(new java.awt.Color(204, 255, 204));

        javax.swing.GroupLayout jpBarraBotoesLayout = new javax.swing.GroupLayout(jpBarraBotoes);
        jpBarraBotoes.setLayout(jpBarraBotoesLayout);
        jpBarraBotoesLayout.setHorizontalGroup(
            jpBarraBotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 542, Short.MAX_VALUE)
        );
        jpBarraBotoesLayout.setVerticalGroup(
            jpBarraBotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 51, Short.MAX_VALUE)
        );

        jpFundoPrincipal.add(jpBarraBotoes, java.awt.BorderLayout.PAGE_START);

        fileMenu.setText("Cadastro");

        openMenuItem.setText("Tipo de Conta");
        openMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(openMenuItem);

        mbMenu.add(fileMenu);

        editMenu.setText("Manutenção");

        cutMenuItem.setText("Contas a Receber");
        cutMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cutMenuItemActionPerformed(evt);
            }
        });
        editMenu.add(cutMenuItem);

        copyMenuItem.setText("Contas a Pagar");
        editMenu.add(copyMenuItem);

        mbMenu.add(editMenu);

        jMenu1.setText("Consulta");

        jMenuItem1.setText("Contas a Receber");
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("Contas a Pagar");
        jMenu1.add(jMenuItem2);

        mbMenu.add(jMenu1);

        helpMenu.setText("Sair");

        contentMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_MASK));
        contentMenuItem.setText("Finalizar");
        contentMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                contentMenuItemActionPerformed(evt);
            }
        });
        helpMenu.add(contentMenuItem);

        mbMenu.add(helpMenu);

        jMenu2.setText("Daniel");

        jMenuItem3.setText("Look And Feel");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem3);

        mbMenu.add(jMenu2);

        setJMenuBar(mbMenu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpFundoPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 542, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpFundoPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-560)/2, (screenSize.height-402)/2, 560, 402);
    }// </editor-fold>//GEN-END:initComponents

    private void contentMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_contentMenuItemActionPerformed

        System.exit(0);
    }//GEN-LAST:event_contentMenuItemActionPerformed

    private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed

        try {
            if (VerificaFrame.verificaFrame(dpPrincipal, tcv) != true) {
                // JOptionPane.showMessageDialog(null, " vou criar");
                tcv = new TipoContaVisao();
                dpPrincipal.add(tcv);
                // tcv.setLocation(10, 10);
                ///tcv.setMaximizable(true);

            } else {
                JOptionPane.showMessageDialog(null, " Já está aberto");
                tcv.setIcon(false);
            }
            tcv.setVisible(true);
        } catch (Exception ey) {
            JOptionPane.showMessageDialog(null, ey.getMessage());
        }


    }//GEN-LAST:event_openMenuItemActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        UIManager.LookAndFeelInfo[] instalados = UIManager.getInstalledLookAndFeels();
        Integer num;
        num = 0;
        //num = Integer.parseInt(jTextField1.getText());
        JOptionPane.showMessageDialog(null, instalados);
        num = Integer.parseInt(JOptionPane.showInputDialog("Informe o número de 0 até " + instalados.length, num));


        try {
            UIManager.setLookAndFeel(instalados[num].getClassName());
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "erro..." + e);
        }
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void cutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cutMenuItemActionPerformed
        try {
            if (VerificaFrame.verificaFrame(dpPrincipal, cm) != true) {
                cm = new CadastroModelo();
                dpPrincipal.add(cm);
                //cm.setLocation(10, 10);
                //tcv.setMaximizable(true);

            } else {
                JOptionPane.showMessageDialog(null, " Já está aberto");
                cm.setIcon(false);
            }
            cm.setVisible(true);
        } catch (Exception ey) {
            JOptionPane.showMessageDialog(null, ey.getMessage());
        }

    }//GEN-LAST:event_cutMenuItemActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

        try {
            if (VerificaFrame.verificaFrame(dpPrincipal, dc) != true) {
                dc = new Daniel_Cadastro();
                dpPrincipal.add(dc);

            } else {
                JOptionPane.showMessageDialog(null, " Já está aberto");
                dc.setIcon(false);
            }
            dc.setVisible(true);
        } catch (Exception ey) {
            JOptionPane.showMessageDialog(null, ey.getMessage());
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

        try {
            if (VerificaFrame.verificaFrame(dpPrincipal, te) != true) {
                te = new teste();
                dpPrincipal.add(te);

            } else {
                JOptionPane.showMessageDialog(null, " Já está aberto");
                te.setIcon(false);
            }
            te.setVisible(true);
        } catch (Exception ey) {
            JOptionPane.showMessageDialog(null, ey.getMessage());
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

        try {
            if (VerificaFrame.verificaFrame(dpPrincipal, vh) != true) {
                vh = new ValidandoHeranca();
                dpPrincipal.add(vh);

            } else {
                JOptionPane.showMessageDialog(null, " Já está aberto");
                vh.setIcon(false);
            }
            vh.setVisible(true);
        } catch (Exception ey) {
            JOptionPane.showMessageDialog(null, ey.getMessage());
        }

    }//GEN-LAST:event_jButton4ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Menu().setVisible(true);



            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem contentMenuItem;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JDesktopPane dpPrincipal;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JPanel jpAreaTrabalho;
    private javax.swing.JPanel jpBarraBotoes;
    private javax.swing.JPanel jpFundoPrincipal;
    private javax.swing.JPanel jpRodape;
    private javax.swing.JMenuBar mbMenu;
    private javax.swing.JMenuItem openMenuItem;
    // End of variables declaration//GEN-END:variables
}
